<template>
	<view class="content" :style="'background:#f7f7f7;'">
		<view class="ad-image">
			<ad style="height: 100%;" :unit-id="luttery_config.wx_prizedraw_banner_adv_key"></ad>
		</view>
		<text class="join-user-number font28" :style="'color:#111111;'">{{total}}位参与者</text>
		<view class="user-avatar-image-list">
			<block v-for="(item, index) in lutteryList" :key="index">
				<image class="user-avatar" :src="item.avatar" mode=""></image>
			</block>
		</view>
		<view class="load-more" :style="'color:#7c7c7c;'" @click="loadmore">
			加载更多
		</view>
	</view>
</template>

<script>
	var util = require('@/js/util.js')
	export default {
		data() {
			return {
				lutteryList:[],
				luttery_id:'',
<<<<<<< HEAD
				total:0
=======
				page:1,
				size:100,
				luttery_config:''
>>>>>>> 263842a02420c7090936b7737331a37d9618b572
			};
		},
		onShareAppMessage() { // 分享 buttom share
			return {
				title: '抽奖助手',
				path: '/pages/index/index?parent_id='+uni.getStorageSync('member_id')+'&prizedraw_id='+this.luttery_id
			}
		},
		onLoad(e) {
			this.luttery_config = uni.getStorageSync("luttery_config")
			this.luttery_id = e.id
			this.getUserList()
		},
		methods:{
			loadmore(){
				this.page ++
				this.getUserList()
			},
			getUserList(){
				let _self = this
				uni.request({
					url: util.getUrl("prizedraw/memberList"),
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation':uni.getStorageSync("token")
					},
					data:{
						prizedraw_id:_self.luttery_id,
						page:_self.page,
						size:_self.size
					},
					method: 'POST',
					success: res => {
						if(res.data.code == 1){
<<<<<<< HEAD
							_self.lutteryList = res.data.data.list
							_self.total = res.data.data.total
=======
							if(this.page == 1){
								if(res.data.data.length <=0){
									uni.showToast({
										title:'暂无更多信息',
										icon:'none'
									})
								}else{
									_self.lutteryList = res.data.data
								}
								
							}else if(res.data.data.length <=0){
								_self.page --
								uni.showToast({
									title:'暂无更多信息',
									icon:'none'
								})
							}else{
								for(let key in res.data.data){
									_self.lutteryList.push(res.data.data[key])
								}
							}
>>>>>>> 263842a02420c7090936b7737331a37d9618b572
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
							if(res.data.code == 500){
								uni.navigateTo({
									url:'../../../pages/login/login'
								})
							}
						}
					},
				});
			},
		}
	}
</script>

<style lang="scss">
	.load-more{
		margin-top: 30upx;
		font-size: 28upx;
	}
	.user-avatar-image-list{
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		margin-right:-10upx;
		.user-avatar{
			width: 60upx;
			height: 60upx;
			margin-right: 10upx;
			margin-bottom: 10upx;
		}
	}
	.join-user-number{
		margin-top: 30upx;
		margin-bottom: 30upx;
	}
	.ad-image{
		width: 690upx;
		height: 190upx;
		margin-top: 30upx;
		margin-bottom: 38upx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.content{
		width: 750upx;
		min-height: 100vh;
		display: flex;
		align-items: center;
		flex-direction: column;
		box-sizing: border-box;
		padding: 30upx;
		font-family: PingFang SC;
	}
</style>
